package com.zhang.servicepassengeruser.controller;

import com.zhang.internalcommon.dto.VerificationCodeDTO;
import com.zhang.internalcommon.dto.ResponseResult;
import com.zhang.servicepassengeruser.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class UserController {
	@Autowired
	private UserService userService;

	@PostMapping("/user")
	public ResponseResult loginOrRegister(@RequestBody VerificationCodeDTO verificationCodeDTO) {
		String passengerPhone = verificationCodeDTO.getPassengerPhone();
		ResponseResult result = userService.loginOrRegister(passengerPhone);
		return result;
	}

	@GetMapping("/user/{phone}")
	public ResponseResult getUser(@PathVariable("phone") String phone) {
		// String passengerPhone = verificationCodeDTO.getPassengerPhone();
		return userService.getUserByPhone(phone);
	}
}
